package com.cz.fra.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.cz.fra.dao.SpeciesDao;
import com.cz.fra.utils.DBUtil;

public class JdbcSpecieDao implements SpeciesDao{

	DBUtil dbUtil = new DBUtil();
	
	@Override
	public List<String> getSpecies() {
		String get_species_list = "select species_name from "+ DBUtil.databaseName +".frs_species";
		List<String> speciesList = new ArrayList<String>();
		ResultSet rs = null;
		dbUtil.getConnection();
		try {
			rs = dbUtil.executeQuery(get_species_list);
			while(rs.next()){
				speciesList.add(rs.getString("species_name"));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally{
			if(rs != null){
				try {
					rs.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			dbUtil.closeConnection();
		}
		return speciesList;
	}

}
